library(tidyverse)
## -- Attaching packages ----------------------------------------------------------- tidyverse 1.3.0 --
## √ ggplot2 3.2.1 √ purrr 0.3.3
## √ tibble 2.1.3 √ dplyr 0.8.4
## √ tidyr 1.0.2 √ stringr 1.4.0
## √ readr 1.3.1 √ forcats 0.5.0
## Warning: package 'forcats' was built under R version 3.6.3
## -- Conflicts -------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
info <- read.csv("../data/train_set/label.csv")
load("../output/all_points.Rdata")
emo_idx = map(1:22, ~info$emotion_idx == .x)
group_points = map(emo_idx, ~all_points[.x])
ave_points = NULL
for (i in 1:length(group_points)){
mean = matrix(rep(0,78*2), nc = 2)
l = length(group_points[[i]])
for(j in 1:l){
group_points[[i]][[j]]
mean = mean + group_points[[i]][[j]]/l
}
ave_points = c(ave_points, list(mean))
}
draw_face = function(points, col){
g1 = c(2:9,2)
g2 = c(11:18,11)
g3 = c(19:26,19)
g4 = c(27:34,27)
g5 = c(39:49,39)
g6 = c(50:57,50)
g7 = c(58:63,58)
g8 = c(64:78)
lines(points[g1,1],-points[g1,2], col = col)
lines(points[g2,1],-points[g2,2], col = col)
lines(points[g3,1],-points[g3,2], col = col)
lines(points[g4,1],-points[g4,2], col = col)
lines(points[g5,1],-points[g5,2], col = col)
lines(points[g6,1],-points[g6,2], col = col)
lines(points[g7,1],-points[g7,2], col = col)
lines(points[g8,1],-points[g8,2], col = col)
}
name = info$emotion_cat %>% unique()
for(i in 1:21){
for(j in (i+1):22){
plot(ave_points[[i]][,1], -ave_points[[i]][,2], xlim = c(140, 860), ylim = c(-680, -140), pch = 16, col = 'blue',cex = 0.5)
draw_face(ave_points[[i]], 'blue')
points(ave_points[[j]][,1], -ave_points[[j]][,2], pch = 16, col = 'red', cex = 0.5)
draw_face(ave_points[[j]], 'red')
title(paste0('Blue: ', name[i], ' V.S. Red: ', name[j]))
}
}






































































































































































































































